<?php


namespace library;


class common
{
    /**
     * @param $path
     * @param $namespace
     * @return array|bool
     * 获取当前文件夹下所有文件
     */
     public static function open_autoload_dir($path,$namespace){
         if(!is_dir($path)){
             return false;
         }
         $arr = array();
         $data = scandir($path);
         foreach ($data as $value){
             if($value != '.' && $value != '..'){
                 $v = self::str_replace($value,$namespace);
                 $arr[] = $v;
             }
         }
         return $arr;
     }


    /**
     * @param $value
     * @param $namespace
     * @return mixed
     * 替换.php
     * 进行加载
     */
     public static function str_replace($value,$namespace){
         $autoload_path = __DIR__."/../app/{$namespace}/{$value}";
         if (is_file($autoload_path)){
             require_once $autoload_path;
         }
         $new = str_replace(".php","",$value);
         return $new;
     }
}